package xianhenyuan.csv.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import xianhenyuan.csv.entity.DemoEntity;
import xianhenyuan.csv.utils.RandomUtil;

import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

@Service
public class demoService {


    private final String candidateChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";


    @Autowired
    private RandomUtil randomUtil;

    public List<DemoEntity> findAll() {

        return IntStream.rangeClosed(1, 20)
                .mapToObj(i -> new DemoEntity(randomUtil.generateRandomChars(candidateChars, 10), randomUtil.generateRandomChars(candidateChars, 5), randomUtil.generateRandomChars(candidateChars, 10), randomUtil.generateRandomChars(candidateChars, 5), randomUtil.generateRandomChars(candidateChars, 10)))
                .collect(Collectors.toList());

    }

}
